import os
from flaskz import create_app, celery
from flaskz.config import CeleryConfig
from extensions.celery_redis_sentinel import register

APP_RUNTIMES_DIR = os.environ.get("APP_RUNTIMES_DIR", "E:/MyJava/python/codes/flaskz/venv")

# has to be called before creating celery app
register()

cfg = os.getenv('STOCK_CONFIG', 'celery')
print(">>>>>>>>>>>>> 当前使用的参数配置是[%s] <<<<<<<<<<<<<<<" % cfg)
flask_app = create_app(cfg, cfg_path=os.path.join(APP_RUNTIMES_DIR, 'conf.d', 'config.json'))
flask_app.app_context().push()
celery.init_app(flask_app)
celery.config_from_object(CeleryConfig)
